import {Injectable} from "@angular/core";
import {Http} from "@angular/http";
import {HttpService} from "../../HttpService";
import {ms_loginUser} from "../../model/ms_loginUser"

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';

import {ResponseData} from "../../model/ResponseData";
import {UserToken} from "../../model/UserToken";
import {MD5} from "../../units/md5";


/**
 * 注册
 */
@Injectable()
export class RegisterService extends HttpService{

    protected url="Regesist";


    constructor(private http:Http){
        super();
    }

    public SignIn(user:ms_loginUser):Promise<ResponseData<UserToken>>{

        return this.http.put(this.prefix + this.url,
            {
                userName:user.userName,
                password:user.encrypt()
            })
            .map(response => {
                return response.json() as ResponseData<UserToken>;
            }).toPromise();
    }


}